home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / ZISUB.CPP < prev    next >
C/C++ Source or Header  |  1993-08-09  |  6KB  |  207 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    zn.cpp
  5. //   Title:    Zinc Window Template
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class ZI_SUBSCRIBE.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <zi.hpp>
  41. #define USE_WIN_SUBSCRIBE
  42. #if OS_DOS
  43. #include <zid.hpp>
  44. #elif OS_WINDOWS
  45. #include <ziw.hpp>
  46. #else
  47. #include <zio.hpp>
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //   Description:    Default constructor
  53. //    Parameters:
  54. //       Returns:    
  55. //----------------------------------------------------------------------------
  56. FN_M ZI_SUBSCRIBE::ZI_SUBSCRIBE()
  57. : ZN_WINDOW("WIN_SUBSCRIBE", ZN_LOAD_CENTER|ZN_LOAD_NO_SHOW)
  58. {
  59.     ZI_SUBSCRIBE::Initialize(CL_INIT_CLASS);
  60.     Setup();
  61. }
  62.  
  63.  
  64. //----------------------------------------------------------------------------
  65. //   Description:    Destructor
  66. //    Parameters:
  67. //       Returns:    
  68. //----------------------------------------------------------------------------
  69. FN_M ZI_SUBSCRIBE::~ZI_SUBSCRIBE()
  70. {
  71.     ZI_SUBSCRIBE::Destroy(FALSE);
  72.     Terminate();
  73. }
  74.  
  75.  
  76. //----------------------------------------------------------------------------
  77. //   Description:    Destroy object. Free any resources used by object.
  78. //                          Normally called by destructor.
  79. //                        Should allow multiple calls from various classes.
  80. //                        A class should almost always re-init its variables when 
  81. //                        it is destroyed to prevent accidents.
  82. //    Parameters:    fDestroyAll        Destroy parents also?
  83. //                                            Default is TRUE.
  84. //       Returns:    TRUE if successful.
  85. //----------------------------------------------------------------------------
  86. BOOL FN_M ZI_SUBSCRIBE::Destroy(BOOL fDestroyAll)
  87. {
  88.     ZI_SUBSCRIBE::Initialize(CL_INIT_CLASS_VARS);
  89.     if (fDestroyAll)                            // Destroy parent.
  90.         ZI_SUBSCRIBE_PARENT::Destroy(fDestroyAll);
  91.     return TRUE;
  92. }
  93.  
  94.  
  95. //----------------------------------------------------------------------------
  96. //   Description:    Initialize object. 
  97. //                          Normally called by constructor.
  98. //                        Should allow multiple calls from various classes.
  99. //    Parameters:    sInit        Initialization code. May be one of the following:
  100. //                                        CL_INIT_CLASS            Reset class variables and
  101. //                                                                    and dynamic allocations for
  102. //                                                                    this class only.
  103. //                                        CL_INIT_CLASS_VARS    Reset class variables for
  104. //                                                                    this class only.
  105. //                                        CL_INIT_VARS            Reset class variables for
  106. //                                                                    this class only.
  107. //                                        CL_INIT_ALL                Initialize class and all 
  108. //                                                                    parent class, including
  109. //                                                                    dynamic memory allocation.
  110. //                                    Default is CL_INIT_ALL
  111. //       Returns:    TRUE if successful.
  112. //----------------------------------------------------------------------------
  113. BOOL FN_M ZI_SUBSCRIBE::Initialize(SHORT sInit)
  114. {
  115.     if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
  116.         ZI_SUBSCRIBE_PARENT::Initialize(sInit);
  117.  
  118.     if (sInit == CL_INIT_CLASS_VARS || sInit == CL_INIT_VARS)
  119.         return TRUE;
  120.  
  121.     sLevel = 0;
  122.     for (SIZET i = 0; i < MAX_SUBSCRIBE_LEVEL; ++i)
  123.         SubscribeGenerate(i, szCode[i]);
  124.     return TRUE;
  125. }
  126.  
  127.  
  128. //----------------------------------------------------------------------------
  129. //   Description:    Event monitor function.
  130. //    Parameters:    msg        Event code
  131. //                        pv1            Data pointer 1
  132. //                        pv2            Data pointer 2
  133. //       Returns:    Event code
  134. //----------------------------------------------------------------------------
  135. ZN_MSG FN_M ZI_SUBSCRIBE::User(ZN_MSG msg, PVOID, PVOID)
  136. {
  137.     switch (msg)
  138.         {
  139.         case ZN_MSG_INIT:
  140.             SetButtonState(FID(RADIO_5), TRUE);
  141.             SetString(FID(STR_CODE), szCode[sLevel]);
  142.             return msg;
  143.  
  144.         case ZN_MSG_TERMINATE:
  145.             return msg;
  146.         }
  147.     if (IsError())                                // Error condition
  148.         return msg;
  149.     switch (msg)
  150.         {
  151.         case BUTTON_OK:
  152.             if (!SubscribeVerify(szCode[sLevel], GetString(FID(STR_RESPONSE))))
  153.                 {
  154.              ZincMessageBox("Invalid Code", ZN_MBOX_OK,
  155.                  "I'm sorry. That is an invalid subscription code response. "
  156.                  "Please verify that you have entered a valid code.");
  157.                 }
  158.             else
  159.                 {
  160. static PCSZ pcszName = "RECORD_COUNT";
  161.                 CL_PARM cl_parm;
  162.                 cl_parm.SetName(pcszName);
  163.                 cl_parm.Get(NULL, pcszName);
  164.                 LONG lRecords = (LONG)cl_parm;
  165.                 lRecords += (sLevel + 1) * 5000;
  166.                 cl_parm = lRecords;
  167.                 cl_parm.Set(pcszName);
  168.                 SendMessage(ZiMainWindow(), ZI_MSG_RECORD);
  169.                 Close();
  170.                 }
  171.             break;
  172.  
  173.         case RADIO_5:
  174.             sLevel = 0;
  175.             SetString(FID(STR_CODE), szCode[sLevel]);
  176.             break;
  177.  
  178.         case RADIO_10:
  179.             sLevel = 1;
  180.             SetString(FID(STR_CODE), szCode[sLevel]);
  181.             break;
  182.  
  183.         case RADIO_15:
  184.             sLevel = 2;
  185.             SetString(FID(STR_CODE), szCode[sLevel]);
  186.             break;
  187.  
  188.         case RADIO_20:
  189.             sLevel = 3;
  190.             SetString(FID(STR_CODE), szCode[sLevel]);
  191.             break;
  192.  
  193.         case BUTTON_CANCEL:
  194.             Close();
  195.             break;
  196.  
  197.         case BUTTON_HELP:
  198.             NotDone();
  199.             break;
  200.         }
  201.     return msg;
  202. }
  203. //----------------------------------------------------------------------------
  204. //------------------------------- End of File --------------------------------
  205. //----------------------------------------------------------------------------
  206.  
  207.